package com.veal98.tree;

import com.veal98.bean.TreeNode;

public class ConvertBstToGreaterTree_538 {

    private int sum = 0;

    public TreeNode convertBST(TreeNode root) {
        if (root != null) {
            // 右
            convertBST(root.right);
            // 根
            sum += root.val;
            root.val = sum;
            // 左
            convertBST(root.left);
        }

        return root;
    }

}
